'''python连接hive和presto'''

from impala.dbapi import connect

conn = connect(host='192.168.10.56', 
               port=10000,
               user='work',
               password='work',
               database='log',
               auth_mechanism='PLAIN',
               kerberos_service_name='hive')
cursor = conn.cursor()
cursor.execute('select * from easy_data_log limit 10 ')
print(cursor.fetchall())

from sqlalchemy import *
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import *
import pandas as pd

# 准备语句
sql = "select * from easy_data_log limit 10"

engine1 = create_engine('presto://192.168.10.57:7000/hive/log')

# 获取数据
df = pd.read_sql(sql, engine1)
print (df)
